﻿using System;
using System.Collections.Generic;
using System.Text;
using Spring.Context;
using Spring.Context.Support;

namespace AMSTrademarkClient
{
    internal static class ObjectUtility
    {
        /// <summary>
        /// 封装spring获取对象的方式
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name"></param>
        /// <returns></returns>
        public static T GetObject<T>(string name)
        {
            IApplicationContext context = ContextRegistry.GetContext();
            T obj = (T)context.GetObject(name);
            return obj;
        }

        /// <summary>
        /// 封装spring获取对象的方式
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static object GetObject(string name)
        {
            IApplicationContext context = ContextRegistry.GetContext();
            return context.GetObject(name);
        }

        /// <summary>
        /// 封装了spring获取对象类型的方式
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Type GetType(string name)
        {
            IApplicationContext context = ContextRegistry.GetContext();
            return context.GetType(name);
        }
    }
}
